<template>
  <!-- 页面容器 -->
  <view class="news-page">
    <!-- 顶部标签栏 -->
    <view class="tab-bar">
      <view class="tab-item active">追踪</view>
      <view class="tab-item">话题榜</view>
      <view class="tab-item">观点榜</view>
      <image class="search-icon" src="/static/icon-search.png" mode="widthFix" @click="toSearch"></image>
    </view>

    <!-- 资讯列表 -->
    <view class="news-list">
      <!-- 资讯项1 -->
      <view class="news-item" @click="toDetail(1)">
        <text class="news-title">曼联客场不败场次在英超排名第二，阿森纳27次客场不败</text>
        <text class="news-content">
          曼联客场对阵阿斯顿维拉...最终红魔以3-1的比分战胜了对手。
        </text>
        <view class="stats">
          <text class="view-count">119次</text>
        </view>
      </view>

      <!-- 资讯项2（带话题标签） -->
      <view class="news-item" @click="toDetail(2)">
        <text class="topic-tag">#司机为爱救儿闯红灯#</text>
        <text class="news-content">
          网红司机为救婴儿连闯3红灯，警察查实后取消处罚。
        </text>
        <view class="stats">
          <text class="view-count">1415次</text>
          <image class="hot-icon" src="/static/icon-hot.png" mode="widthFix"></image>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  methods: {
    // 跳转搜索页
    toSearch() {
      uni.navigateTo({ url: "/pages/search/search" });
    },
    // 跳转资讯详情页
    toDetail(id) {
      uni.navigateTo({ url: `/pages/news-detail/detail?id=${id}` });
    }
  }
};
</script>

<style scoped>
/* 页面容器 */
.news-page {
  min-height: 100vh;
  background-color: #fff;
}

/* 顶部标签栏 */
.tab-bar {
  display: flex;
  align-items: center;
  padding: 20rpx 30rpx;
  border-bottom: 1px solid #f5f5f5;
}
.tab-item {
  font-size: 32rpx;
  color: #666;
  margin-right: 40rpx;
  padding-bottom: 8rpx;
}
.tab-item.active {
  color: #000;
  font-weight: bold;
  border-bottom: 3rpx solid #000;
}
.search-icon {
  width: 40rpx;
  height: 40rpx;
  margin-left: auto;
}

/* 资讯列表 */
.news-list {
  padding: 20rpx 30rpx;
}

/* 单个资讯项 */
.news-item {
  padding: 25rpx 0;
  border-bottom: 1px solid #f5f5f5;
}
.news-title {
  font-size: 32rpx;
  color: #000;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 10rpx;
  display: block;
}
.news-content {
  font-size: 28rpx;
  color: #666;
  line-height: 1.4;
  display: block;
}
.topic-tag {
  font-size: 28rpx;
  color: #e63946; /* 话题标签红色 */
  margin-bottom: 10rpx;
  display: block;
}

/* 阅读量统计 */
.stats {
  display: flex;
  align-items: center;
  margin-top: 15rpx;
}
.view-count {
  font-size: 24rpx;
  color: #999;
}
.hot-icon {
  width: 40rpx;
  height: 24rpx;
  margin-left: 10rpx;
}
</style>